<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>详情页面</title>
  <link rel="stylesheet" href="http://at.alicdn.com/t/font_1566133_wopoq29vrt.css">
  <!-- 引入样式文件 -->

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.3.3/lib/index.css">
  <link rel="stylesheet" href="home.css">
</head>

<body>
  <div id="container">
    safsdfsfsssssssssssssssssssssssssssssssssss

    <img :src="detail.thumbnail.url" alt="">
  </div>
  <!--底部导航 end-->
  </div>
  <script src="vue.js"></script>
  <script src="SHA1.js"></script>
  <script src="axios.min.js"></script>
  <script>
    function getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) { return pair[1]; }
      }
      return (false);
    }
    alert(getQueryVariable("id"))

    var now = Date.now();
    var appKey = SHA1("A6013700252001" + "UZ" + "2AE3F19A-AB62-34C7-D81B-BC1FE8123458" + "UZ" + now) + "." + now

    var vm = new Vue({
      el: "#container",
      data: {
        detail: {
          "id": "56c94a0426f863e874c76cb5",
          "unit": "500g",
          "originPrice": 62.9,
          "price": 49.9,
          "stock": 10,
          "name": "月盛斋牛腱子",
          "description": "240余年的老字号 源自月盛斋",
          "thumbnail": {
            "url": "http://a93462f491a52058875c.test.upcdn.net/apicloud/e0b7dbcfaae77c8662d3e9cc3fc75353.jpg",
            "name": "1.png",
            "id": "5d8195a4b2751d4757204a51"
          }
        }
      },
      created: function () {
        this.getDetailData()
      },
      mounted: function () {

      },
      methods: {
        getDetailData: function () {

          var _this = this;
          var param = {
            where: {
              id: getQueryVariable("id")
            }
          }

          axios.get('https://d.apicloud.com/mcm/api/ware?filter=' + JSON.stringify(param), {
            headers: {
              "X-APICloud-AppId": "A6013700252001",
              "X-APICloud-AppKey": appKey
            }
          })
            .then(function (response) {

              _this.detail = response.data[0]
              console.log(response.data);
            })
            .catch(function (error) {
              console.log(error);
            });
        }
      },
    })
  </script>
</body>

</html>